import os
import time
import subprocess

class GPIO:
	def __init__(self, PIN):
		self.PIN = PIN

	def write(self,VAL):
		PATH = '/sys/class/gpio/gpio'+ str(self.PIN) + '/' + 'value'
		with open(PATH, "w") as f:
			f.write(str(VAL))
		return

	def mode(self,MODE):
		PATH = '/sys/class/gpio/gpio'+ str(self.PIN) + '/' + 'direction'
		if (MODE.lower() == 'in'):
			with open(PATH, "w") as f:
				f.write('in')
			
		elif (MODE.lower() == 'out'):
			with open(PATH, "w") as f:
				f.write('out')

		return

	def read(self):
		PATH = '/sys/class/gpio/gpio'+ str(self.PIN) + '/' + 'value'
		with open(PATH, "r") as f:
			x = f.read()
		return x

